{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% block title %}{{'注册'|trans}} - {{ parent() }}{% endblock %}
{% set script_controller = 'auth/register' %}

{% set parameter = get_parameters_from_url(app.request.uri) %}
{% block content %}

<div class="es-section login-section">
  <div class="logon-tab clearfix">
    <a href="{{ path('login', {goto:_target_path}) }}">{{'登录帐号'|trans}}</a>
    <a class="active">{{'注册帐号'|trans}}</a>
  </div>
  <div class="login-main">
    {% if isRegisterEnabled %}
      <form id="register-form" method="post" action="">
        {{ web_macro.flash_messages() }}

        {% if inviteCode != null  %}
          <div class="alert alert-info alert-sm">{{'您正在通过<span class="color-gray mhs">%inviteUser%</span>的邀请注册。'|trans({'%inviteUser%': inviteUser.nickname})|raw}}</div>
        {% endif %}

        {% if setting('auth.register_mode') == 'email' %}
          <div class="form-group mbl">
            <label class="control-label required" for="register_email">{{'邮箱地址'|trans}}</label>
            <div class="controls">
              <input type="email" id="register_email" name="email" required="required" class="form-control input-lg" data-url="{{path('register_email_check')}}" placeholder="{{'填写你常用的邮箱作为登录帐号'|trans}}">
              <p class="help-block"></p>
            </div>
          </div>
        {% elseif setting('auth.register_mode') == 'mobile' %}
          <div class="form-group mbl">
            <label class="control-label required" for="register_mobile">{{'手机号码'|trans}}</label>
            <div class="controls">
              <input type="number" id="register_mobile" name="verifiedMobile" required="required" class="form-control input-lg" data-url="{{path('register_mobile_check')}}" placeholder="{{'填写你常用的手机号码作为登录帐号'|trans}}">
              <p class="help-block"></p>
            </div>
          </div>
        {% else %}
          <div class="form-group mbl">
            <label class="control-label required" for="register_emailOrmobile">{{'手机/邮箱'|trans}}</label>
            <div class="controls">
              <input type="text" id="register_emailOrMobile" name="emailOrMobile" required="required" class="form-control input-lg" data-url="{{path('register_email_or_mobile_check')}}" placeholder="{{'填写你常用的邮箱或手机号码作为登录帐号'|trans}}">
              <p class="help-block"></p>
            </div>
          </div>
        {% endif %}

        <div class="form-group mbl">
          <label class="control-label required" for="register_nickname">{{'用户名'|trans}}</label>
          <div class="controls">
            <input type="text" id="register_nickname" name="nickname" required="required" class="form-control input-lg" data-url="{{path('register_nickname_check')}}" placeholder="{{'中、英文均可，最长18个英文或9个汉字'|trans}}">
            <p class="help-block"></p>
          </div>
        </div>
        <div class="form-group mbl">
          <label class="control-label required" for="register_password">{{'密码'|trans}}</label>
          <div class="controls">
            <input type="password" id="register_password" name="password" required="required" class="form-control input-lg" placeholder="{{'5-20位英文、数字、符号，区分大小写'|trans}}">
            <p class="help-block"></p>
          </div>
        </div>
        {% if (setting('auth.captcha_enabled')|default(0)) == 1 and setting('auth.register_mode') != 'mobile' %}
          <div class="form-group mbl js-captcha">
            <label class="control-label required" for="captcha_code">{{'验证码'|trans}}</label>
            <div class="controls row">
              <div class = "col-xs-7">
                <input type="text" class="form-control input-lg" id="captcha_code" name="captcha_code" maxlength="5" placeholder="{{'验证码'|trans}}" required="required"  data-url="{{path('register_captcha_check')}}" >
                <p class="help-block"></p>
              </div>
              <div class="col-xs-5">
                <img src="{{ path('register_captcha_num') }}" data-url="{{ path('register_captcha_num') }}" id="getcode_num" title="{{'看不清，点击换一张'|trans}}" style="cursor:pointer;height:40px;width:100%">
              </div>
              
            </div>
          </div>
        {% endif %}
        {% if setting('auth.register_mode') == 'email_or_mobile' or setting('auth.register_mode') == 'mobile' %}
          <div class="form-group mbl {% if setting('auth.register_mode') != 'mobile' %}hidden{% endif %} email_mobile_msg">
            <label class="control-label required" for="sms_code">{{'短信验证码'|trans}}</label>
            <div class="controls row" >
              <div class = "col-xs-7" >
                <input type="number" class="form-control input-lg" id="sms_code" name="sms_code" placeholder="{{'填写你的短信验证码'|trans}}" required="required" data-url="{{path('edu_cloud_sms_check',{type:'sms_registration'})}}">
                <p class="help-block"> </p>
              </div>
              <div class="col-xs-5">
                <a href="#modal" data-toggle="modal" class="btn btn-default btn-lg js-sms-send disabled" data-url="{{ path('register_captcha_modal') }}" data-sms-url="{{ path('edu_cloud_sms_send') }}">
                  <span id="js-time-left"></span>
                  <span id="js-fetch-btn-text">{{'获取短信验证码'|trans}}</span>
               </a>
              </div>
            </div>
          </div>
        {% endif %}
        {% if (setting('invite.invite_code_setting')|default(0) == 1) and  inviteCode == null  %}
        <div class="form-group mbl">
          <label class="control-label required" for="invite_code">{{'邀请码'|trans}}<span class="text-success">（{{'选填'|trans}}）</span></label>
          <div class="controls">
            <input type="text" name="invite_code" required="required" class="form-control input-lg invitecode" data-url="{{path('invitecode_check')}}" placeholder="{{'如果您有邀请码，请填写您的邀请码'|trans}}">
          </div>
        </div>
        {% endif %}

        {% if setting('auth.user_terms') == 'opened' %}
          <div class="form-group mbl">
            <div class="controls">
              <label>
                <input type="checkbox" id="user_terms" checked="checked"> {{'我已阅读并同意'|trans}}<a href="{{ path('user_terms') }}" target="_blank">《{{'服务协议'|trans}}》</a>
              </label>
            </div>
          </div>
        {% endif %}

        <div class="form-group mbl">
          <div class="controls">
            <button type="submit" id="register-btn" data-submiting-text="{{'正在提交'|trans}}" class="btn btn-primary btn-lg btn-block">{{'注册'|trans}}</button>
          </div>
        </div>

        <input type="hidden" name="captcha_enabled" value="{{ setting('auth.captcha_enabled') }}" />
        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
        {% if app.request.get('inviteCode', '') %}
        <input type="hidden" id="invite_code" name="invite_code" value="{{ app.request.get('inviteCode', '')}}">
        {% endif %}

      </form>

      {% if setting('login_bind.enabled') %}
        <div class="social-login">
          <span>
            {{ render(controller('TopxiaWebBundle:Login:oauth2LoginsBlock', {targetPath:_target_path,inviteCode:inviteCode|default('')})) }}
          </span>
          <div class="line"></div>
        </div>
      {% endif %}
    {% else %}
      <div class="empty">{{'系统暂时关闭注册，请联系管理员'|trans}}</div>
    {% endif %}
  </div>
</div>
  {% if setting('login_bind.weixinmob_enabled') == '1' %}
    {% do load_script('auth/isWeiXin') %}
  {% endif %}
{% endblock %}